import Vue from "vue";
import VueRouter from "vue-router";
import layout from "@/views/layout/Index.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home/dashboard",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/Index.vue"),
  },
  {
    path: "/home",
    name: "home",
    component: layout,
    meta: { title: "首页", icon: "icon-panel", type: "2" },
    children: [
      {
        path: "dashboard",
        name: "dashboard",
        component: () => import("@/views/dashboard/Index.vue"),
        meta: { title: "仪表盘", type: "2" },
      },
      {
        path: "dashboarddata",
        name: "dashboarddata",
        component: () => import("@/views/dashboard/Data.vue"),
        meta: { title: "设备数据", type: "2" },
      },
    ],
  },
  // 设备的路由和子路由
  {
    path: "/device",
    name: "device",
    component: layout,
    meta: { title: "设备", icon: "icon-luyouqi", type: "2" },
    children: [
      {
        path: "gateway",
        name: "gateway",
        component: () => import("@/views/device/Gateway.vue"),
        meta: { title: "网关", type: "2" },
      },
      {
        path: "chuanganqi",
        name: "chuanganqi",
        component: () => import("@/views/device/Devicegroup.vue"),
        meta: { title: "设备群组", type: "2" },
      },
      {
        path: "devgroup",
        name: "devgroup",
        component: () => import("@/views/device/Chuanganqi.vue"),
        meta: { title: "传感器列表", type: "2" },
      },
    ],
  },
  // 计费的路由和子路由
  {
    path: "/fee",
    name: "fee",
    component: layout,
    meta: { title: "计费", icon: "icon-fyxx", type: "2" },
    children: [
      {
        path: "zhanghu",
        name: "zhanghu",
        component: () => import("@/views/fee/Zhanghu.vue"),
        meta: { title: "账户信息", type: "2" },
      },
      {
        path: "chongzhi",
        name: "chongzhi",
        component: () => import("@/views/fee/Chongzhi.vue"),
        meta: { title: "充值记录", type: "2" },
      },
      {
        path: "shiyong",
        name: "shiyong",
        component: () => import("@/views/fee/Shiyong.vue"),
        meta: { title: "使用记录", type: "2" },
      },
    ],
  },
  // 测量类型的路由和子路由
  {
    path: "/measurement",
    name: "measurement",
    component: layout,
    meta: { title: "测量类型", icon: "icon-signal", type: "2" },
    children: [
      {
        path: "adduser",
        name: "adduser",
        component: () => import("@/views/measurement/Addlist.vue"),
        meta: { title: "添加测量类型", type: "2" },
      },
      {
        path: "userlist",
        name: "userlist",
        component: () => import("@/views/measurement/list.vue"),
        meta: { title: "测量类型列表", type: "2" },
      },
    ],
  },
  // 安全的路由和子路由
  {
    path: "/security",
    name: "security",
    component: layout,
    meta: { title: "安全", icon: "icon-anquan", type: "1" },
    children: [
      {
        path: "addmiyao",
        name: "addmiyao",
        component: () => import("@/views/security/Addmiyao.vue"),
        meta: { title: "添加秘钥", type: "1" },
      },
      {
        path: "miyaolist",
        name: "miyaolist",
        component: () => import("@/views/security/Miyaolist.vue"),
        meta: { title: "秘钥列表", type: "1" },
      },
    ],
  },
  // 用户的路由和子路由
  {
    path: "/users",
    name: "users",
    component: layout,
    meta: { title: "账号", icon: "icon-account", type: "1" },
    children: [
      {
        path: "addusers",
        name: "addusers",
        component: () => import("@/views/users/Adduser.vue"),
        meta: { title: "添加用户", type: "1" },
      },
      {
        path: "userslist",
        name: "userslist",
        component: () => import("@/views/users/Userlist.vue"),
        meta: { title: "账号列表", type: "1" },
      },
    ],
  },
  {
    path: "*",
    name: "page404",
    component: () => import("@/views/page404/Index.vue"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
